<!DOCTYPE html>

<html>
<head>
<meta content="text/html; charset=CP852" http-equiv="Content-Type">

<title>class ExistAPI - RDoc Documentation</title>

<link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
</script>

<script type="text/javascript" charset="utf-8" src="./js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/navigation.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/search_index.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/search.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/searcher.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/darkfish.js"></script>


<body id="top" class="class">
<nav id="metadata">
  <nav id="home-section" class="section">
  <h3 class="section-header">
    <a href="./index.html">Home</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </h3>
</nav>


  <nav id="search-section" class="section project-section" class="initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <h3 class="section-header">
      <input type="text" name="search" placeholder="Search" id="search-field"
             title="Type to search, Up and Down to navigate, Enter to load">
    </h3>
  </form>

  <ul id="search-results" class="initially-hidden"></ul>
</nav>


  <div id="file-metadata">
    <nav id="file-list-section" class="section">
  <h3 class="section-header">Defined In</h3>
  <ul>
    <li>lib/eXistAPI.rb
  </ul>
</nav>

    
  </div>

  <div id="class-metadata">
    
    <nav id="parent-class-section" class="section">
  <h3 class="section-header">Parent</h3>
  
  <p class="link">Object
  
</nav>

    
    <!-- Method Quickref -->
<nav id="method-list-section" class="section">
  <h3 class="section-header">Methods</h3>

  <ul class="link-list">
    
    <li><a href="#method-c-new">::new</a>
    
    <li><a href="#method-i-createcollection">#createcollection</a>
    
    <li><a href="#method-i-execute_query">#execute_query</a>
    
    <li><a href="#method-i-existscollection-3F">#existscollection?</a>
    
    <li><a href="#method-i-get_hits">#get_hits</a>
    
    <li><a href="#method-i-getcollection">#getcollection</a>
    
    <li><a href="#method-i-remove_collection">#remove_collection</a>
    
    <li><a href="#method-i-retrieve">#retrieve</a>
    
    <li><a href="#method-i-storeresource">#storeresource</a>
    
    <li><a href="#method-i-update_delete">#update_delete</a>
    
    <li><a href="#method-i-update_insert">#update_insert</a>
    
    <li><a href="#method-i-update_rename">#update_rename</a>
    
    <li><a href="#method-i-update_replace">#update_replace</a>
    
    <li><a href="#method-i-update_value">#update_value</a>
    
  </ul>
</nav>

  </div>

  <div id="project-metadata">
    <nav id="fileindex-section" class="section project-section">
  <h3 class="section-header">Pages</h3>

  <ul>
  
    <li class="file"><a href="./LICENSE.html">LICENSE</a>
  
    <li class="file"><a href="./README.html">README</a>
  
    <li class="file"><a href="./Rakefile.html">Rakefile</a>
  
    <li class="file"><a href="./nbproject/private/rake-d_txt.html">rake-d</a>
  
  </ul>
</nav>

    <nav id="classindex-section" class="section project-section">
  <h3 class="section-header">Class and Module Index</h3>

  <ul class="link-list">
  
    <li><a href="./Collection.html">Collection</a>
  
    <li><a href="./Document.html">Document</a>
  
    <li><a href="./ExistAPI.html">ExistAPI</a>
  
    <li><a href="./ExistException.html">ExistException</a>
  
    <li><a href="./TestExistAPI.html">TestExistAPI</a>
  
  </ul>
</nav>

  </div>
</nav>

<div id="documentation">
  <h1 class="class">class ExistAPI</h1>

  <div id="description" class="description">
    
<p><a href="ExistAPI.html">ExistAPI</a> is comunication interface to eXist-db
based on XML-RPC. With eXistAPI  you are able to create, delete or get
collections or retrieve whole content of  documents or part of it by
querying.  Also with eXistAPI you can work with documents stored in
eXist-db.  You can insert, replace, rename and delete nodes or change
values. To query use xQuery or xPath.</p>

<pre>==== Examples</pre>

<p>db = <a href="ExistAPI.html#method-c-new">::new</a>("<a
href="http://localhost:8080/exist/xmlrpc">localhost:8080/exist/xmlrpc</a>",
"admin", "admin") puts db.existscollection?("db")</p>

  </div><!-- description -->

  
  
  
  <section id="5Buntitled-5D" class="documentation-section">
    

    

    

    

    <!-- Methods -->
    
     <section id="public-class-5Buntitled-5D-method-details" class="method-section section">
      <h3 class="section-header">Public Class Methods</h3>

    
      <div id="method-c-new" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">new</span><span
            class="method-args">(uri = nil , username = nil, password = nil)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Create new instance of <a href="ExistAPI.html">ExistAPI</a>.</p>

<p>example <a href="ExistAPI.html#method-c-new">::new</a>("<a
href="http://localhost:8080/exist/xmlrpc">localhost:8080/exist/xmlrpc</a>",
"admin", "password")</p>

<pre>* *Args*    :
  - +uri+ -&gt; uri of the db server
  - +username+ -&gt; username
  - +password+  -&gt; password to specified username
* *Returns* :
  - new instance of ExistAPI
* *Raises* :
  - +ExistException+ -&gt; Database login failed</pre>
          

          
          <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File lib/eXistAPI.rb, line 31</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">uri</span> = <span class="ruby-keyword">nil</span> , <span class="ruby-identifier">username</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">password</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-ivar">@uri</span> = <span class="ruby-identifier">uri</span>
  <span class="ruby-ivar">@username</span> = <span class="ruby-identifier">username</span>
  <span class="ruby-ivar">@password</span> = <span class="ruby-identifier">password</span>
  <span class="ruby-ivar">@parameters</span> = { <span class="ruby-string">&quot;encoding&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;UTF-8&quot;</span>, <span class="ruby-string">&quot;indent&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;yes&quot;</span>}
  <span class="ruby-identifier">connect</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- new-source -->
          
        </div>

        

        
      </div><!-- new-method -->

    
    </section><!-- public-class-method-details -->
  
     <section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
      <h3 class="section-header">Public Instance Methods</h3>

    
      <div id="method-i-createcollection" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">createcollection</span><span
            class="method-args">(name, parent_col = nil)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Creates collection with name in parrent(optionaly)</p>

<pre>* *Args*    :
  - +name+ -&gt; the name of collection
* *Returns* :
  - the result of call
* *Raises* :
  - +ExistException+ -&gt; if collection is not created.</pre>
          

          
          <div class="method-source-code" id="createcollection-source">
            <pre><span class="ruby-comment"># File lib/eXistAPI.rb, line 92</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">createcollection</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">parent_col</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">name</span> = <span class="ruby-identifier">check_slashes</span>(<span class="ruby-identifier">name</span>)
  <span class="ruby-keyword">if</span> (<span class="ruby-identifier">parent_col</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span>)
    <span class="ruby-keyword">begin</span>
      <span class="ruby-identifier">result</span> = <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">call</span>(<span class="ruby-string">&quot;createCollection&quot;</span>, <span class="ruby-identifier">name</span>)
      <span class="ruby-keyword">return</span> <span class="ruby-identifier">result</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">begin</span>
      <span class="ruby-identifier">colname</span> = <span class="ruby-identifier">parent_col</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">name</span>
      <span class="ruby-identifier">result</span> = <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">call</span>(<span class="ruby-string">&quot;createCollection&quot;</span>, <span class="ruby-identifier">colname</span>)
      <span class="ruby-keyword">return</span> <span class="ruby-identifier">result</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">XMLRPC</span><span class="ruby-operator">::</span><span class="ruby-constant">FaultException</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>    
<span class="ruby-keyword">rescue</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">ExistException</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;Failed to create Collection&quot;</span>, <span class="ruby-value">2</span>), <span class="ruby-identifier">caller</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- createcollection-source -->
          
        </div>

        

        
      </div><!-- createcollection-method -->

    
      <div id="method-i-execute_query" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">execute_query</span><span
            class="method-args">(xquery, parameters = @parameters)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Executes an XQuery and returns a reference identifier to the generated
result set. This reference can be used later to retrieve results.</p>

<pre>* *Args*    :
  - +xquery+ -&gt; String xquery. A valid XQuery expression.
  - +parameters+ -&gt; HashMap parameters. The parameters a HashMap values.</pre>

<p>sort-expr : namespaces : variables : base-uri : static-documents :
protected :</p>

<pre>* *Returns* :
  -int, handle of query
* *Raises* :
  - +ExistException+ -&gt; Failed to execute query</pre>
          

          
          <div class="method-source-code" id="execute_query-source">
            <pre><span class="ruby-comment"># File lib/eXistAPI.rb, line 231</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">execute_query</span>(<span class="ruby-identifier">xquery</span>, <span class="ruby-identifier">parameters</span> = <span class="ruby-ivar">@parameters</span>)
  <span class="ruby-comment">#puts xquery</span>
  <span class="ruby-keyword">begin</span>
    <span class="ruby-identifier">handle</span> = <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">call</span>(<span class="ruby-string">&quot;executeQuery&quot;</span>, <span class="ruby-constant">XMLRPC</span><span class="ruby-operator">::</span><span class="ruby-constant">Base64</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xquery</span>), <span class="ruby-identifier">parameters</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">handle</span>
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">XMLRPC</span><span class="ruby-operator">::</span><span class="ruby-constant">FaultException</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>    
  <span class="ruby-keyword">rescue</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ExistException</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;Failed to execute query&quot;</span>, <span class="ruby-value">6</span>), <span class="ruby-identifier">caller</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- execute_query-source -->
          
        </div>

        

        
      </div><!-- execute_query-method -->

    
      <div id="method-i-existscollection-3F" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">existscollection?</span><span
            class="method-args">(orig_path)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Checks if collection with path exists or not.</p>

<pre>* *Args*    :
  - +path+ -&gt; Path of the collection in db.
* *Returns* :
  -boolean. true -&gt; exists, false -&gt; doesn't exist
* *Raises* :
  - +nothing+</pre>
          

          
          <div class="method-source-code" id="existscollection-3F-source">
            <pre><span class="ruby-comment"># File lib/eXistAPI.rb, line 138</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">existscollection?</span>(<span class="ruby-identifier">orig_path</span>)
  <span class="ruby-identifier">orig_path</span> = <span class="ruby-identifier">check_slashes</span>(<span class="ruby-identifier">orig_path</span>)
  <span class="ruby-identifier">collections</span> = <span class="ruby-identifier">orig_path</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&quot;/&quot;</span>)
  <span class="ruby-identifier">collections</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&quot;&quot;</span>)
  <span class="ruby-identifier">i</span>=<span class="ruby-value">0</span>
  <span class="ruby-identifier">path</span> = <span class="ruby-string">&quot;/&quot;</span> 
  <span class="ruby-keyword">while</span>(<span class="ruby-identifier">i</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">collections</span>.<span class="ruby-identifier">length</span>)
    <span class="ruby-identifier">path</span> = <span class="ruby-identifier">path</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">collections</span>[<span class="ruby-identifier">i</span>] <span class="ruby-operator">+</span> <span class="ruby-string">&quot;/&quot;</span>
    <span class="ruby-identifier">col</span> = <span class="ruby-constant">Collection</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@client</span>, <span class="ruby-identifier">path</span>)
    <span class="ruby-keyword">if</span> (<span class="ruby-operator">!</span><span class="ruby-identifier">col</span>.<span class="ruby-identifier">childCollection</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">collections</span>[<span class="ruby-identifier">i</span><span class="ruby-operator">+</span><span class="ruby-value">1</span>]))
      <span class="ruby-keyword">break</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">i</span> = <span class="ruby-identifier">i</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
  <span class="ruby-keyword">end</span>
  
  <span class="ruby-keyword">if</span>(<span class="ruby-identifier">path</span>[<span class="ruby-value">-1</span>]<span class="ruby-operator">==</span><span class="ruby-string">&quot;/&quot;</span>)
    <span class="ruby-identifier">path</span> = <span class="ruby-identifier">path</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">-2</span>]
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span>(<span class="ruby-identifier">orig_path</span>[<span class="ruby-value">-1</span>]<span class="ruby-operator">==</span><span class="ruby-string">&quot;/&quot;</span>)
    <span class="ruby-identifier">orig_path</span> = <span class="ruby-identifier">orig_path</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">-2</span>]
  <span class="ruby-keyword">end</span>
  
  <span class="ruby-keyword">if</span>(<span class="ruby-identifier">path</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">orig_path</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">rescue</span>  =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>  
<span class="ruby-keyword">end</span></pre>
          </div><!-- existscollection-3F-source -->
          
        </div>

        

        
      </div><!-- existscollection-3F-method -->

    
      <div id="method-i-get_hits" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">get_hits</span><span
            class="method-args">(handle)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Get the number of hits in the result-set identified by resultId. example:
gethits(handle_id)</p>

<pre>* *Args*    :
  - +handle+ -&gt; Reference to a result-set as returned by a previous call to executeQuery.
* *Returns* :
  -the number of hits
* *Raises* :
  - +ExistException+ -&gt; Failed to get number of hits</pre>
          

          
          <div class="method-source-code" id="get_hits-source">
            <pre><span class="ruby-comment"># File lib/eXistAPI.rb, line 276</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">get_hits</span>(<span class="ruby-identifier">handle</span>)
  <span class="ruby-keyword">begin</span>
    <span class="ruby-identifier">summary</span> = <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">call</span>(<span class="ruby-string">&quot;querySummary&quot;</span>, <span class="ruby-identifier">handle</span>)
    <span class="ruby-identifier">hits</span> = <span class="ruby-identifier">summary</span>[<span class="ruby-string">'hits'</span>]
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">hits</span>
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">XMLRPC</span><span class="ruby-operator">::</span><span class="ruby-constant">FaultException</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>
  <span class="ruby-keyword">rescue</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ExistException</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;Failed to get number of hits&quot;</span>, <span class="ruby-value">8</span>), <span class="ruby-identifier">caller</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- get_hits-source -->
          
        </div>

        

        
      </div><!-- get_hits-method -->

    
      <div id="method-i-getcollection" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">getcollection</span><span
            class="method-args">(path)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Returns <a href="Collection.html">Collection</a> at specified path.</p>

<pre class="ruby">* *<span class="ruby-constant">Args</span>*    <span class="ruby-operator">:</span>
  <span class="ruby-operator">-</span> <span class="ruby-operator">+</span><span class="ruby-identifier">path</span><span class="ruby-operator">+</span> <span class="ruby-operator">-</span><span class="ruby-operator">&gt;</span> <span class="ruby-constant">Path</span> <span class="ruby-identifier">of</span> <span class="ruby-identifier">the</span> <span class="ruby-identifier">collection</span> <span class="ruby-keyword">in</span> <span class="ruby-identifier">db</span>.
* *<span class="ruby-constant">Returns</span>* <span class="ruby-operator">:</span>
  <span class="ruby-operator">-</span><span class="ruby-identifier">instance</span> <span class="ruby-identifier">of</span> <span class="ruby-keyword">class</span> <span class="ruby-constant">Collection</span>.
* *<span class="ruby-constant">Raises</span>* <span class="ruby-operator">:</span>
  <span class="ruby-operator">-</span> <span class="ruby-operator">+</span><span class="ruby-identifier">nothing</span><span class="ruby-operator">+</span>
</pre>
          

          
          <div class="method-source-code" id="getcollection-source">
            <pre><span class="ruby-comment"># File lib/eXistAPI.rb, line 121</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">getcollection</span>(<span class="ruby-identifier">path</span>)
  <span class="ruby-identifier">path</span> = <span class="ruby-identifier">check_slashes</span>(<span class="ruby-identifier">path</span>)
  <span class="ruby-identifier">col</span> = <span class="ruby-constant">Collection</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@client</span>, <span class="ruby-identifier">path</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">col</span>
<span class="ruby-keyword">rescue</span>  =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>  
<span class="ruby-keyword">end</span></pre>
          </div><!-- getcollection-source -->
          
        </div>

        

        
      </div><!-- getcollection-method -->

    
      <div id="method-i-remove_collection" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">remove_collection</span><span
            class="method-args">(path)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Removes collection with specified path.</p>

<pre>* *Args*    :
  - +path+ -&gt; Path of the collection in db.
* *Returns* :
  - the result of call
* *Raises* :
  - +ExistException+ -&gt; if failed to remove collection.</pre>
          

          
          <div class="method-source-code" id="remove_collection-source">
            <pre><span class="ruby-comment"># File lib/eXistAPI.rb, line 179</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">remove_collection</span>(<span class="ruby-identifier">path</span>)
  <span class="ruby-identifier">result</span> = <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">call</span>(<span class="ruby-string">&quot;removeCollection&quot;</span>, <span class="ruby-identifier">path</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">result</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">XMLRPC</span><span class="ruby-operator">::</span><span class="ruby-constant">FaultException</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>    
<span class="ruby-keyword">rescue</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">ExistException</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;Failed to remove Collection&quot;</span>, <span class="ruby-value">3</span>), <span class="ruby-identifier">caller</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- remove_collection-source -->
          
        </div>

        

        
      </div><!-- remove_collection-method -->

    
      <div id="method-i-retrieve" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">retrieve</span><span
            class="method-args">(handle, pos)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Retrieves a single result-fragment from the result-set referenced by
resultId.  The result-fragment is identified by its position in the
result-set, which is passed in the parameter pos.</p>

<pre>* *Args*    :
  - +handle+ -&gt; Reference to a result-set as returned by a previous call to executeQuery.
  - +pos+ -&gt; The position of the item in the result-sequence, starting at 0.
  - +parameters+ -&gt; A struct containing key=value pairs to configure the output.
* *Returns* :
  - the result of call
* *Raises* :
  - +ExistException+ -&gt; Failed to retrive resource</pre>
          

          
          <div class="method-source-code" id="retrieve-source">
            <pre><span class="ruby-comment"># File lib/eXistAPI.rb, line 255</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">retrieve</span>(<span class="ruby-identifier">handle</span>, <span class="ruby-identifier">pos</span>)
  <span class="ruby-keyword">begin</span>
    <span class="ruby-identifier">res</span> = <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">call</span>(<span class="ruby-string">&quot;retrieve&quot;</span>, <span class="ruby-identifier">handle</span>, <span class="ruby-identifier">pos</span>, <span class="ruby-ivar">@parameters</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">res</span>
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">XMLRPC</span><span class="ruby-operator">::</span><span class="ruby-constant">FaultException</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>   
  <span class="ruby-keyword">rescue</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ExistException</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;Failed to retrive resource&quot;</span>, <span class="ruby-value">7</span>), <span class="ruby-identifier">caller</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- retrieve-source -->
          
        </div>

        

        
      </div><!-- retrieve-method -->

    
      <div id="method-i-storeresource" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">storeresource</span><span
            class="method-args">(_res, _docname, _overwrite = 1)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Stores resource to document in db. Inserts a new document into the database
or replace an existing one:</p>

<pre>* *Args*    :
  - +_res+ -&gt; resource which you want to safe. XML content of this document as a UTF-8 encoded byte array.
  - +_docname+ -&gt; name of the document where to safe. Path to the database location where the new document is to be stored.
  - +_overwrite+ -&gt; Set this value to &gt; 0 to automatically replace an existing document at the same location.
* *Returns* :
  - boolean, the result of the call 
* *Raises* :
  - +ExistException+ -&gt; Resource or document name is nil
  - +ExistException+ -&gt; Failed to store resource&quot;</pre>
          

          
          <div class="method-source-code" id="storeresource-source">
            <pre><span class="ruby-comment"># File lib/eXistAPI.rb, line 200</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">storeresource</span>(<span class="ruby-identifier">_res</span>, <span class="ruby-identifier">_docname</span>, <span class="ruby-identifier">_overwrite</span> = <span class="ruby-value">1</span>)
  <span class="ruby-keyword">if</span> ((<span class="ruby-identifier">_res</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span>)<span class="ruby-operator">||</span>(<span class="ruby-identifier">_docname</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span>))
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ExistException</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;Resource or document name is nil&quot;</span>, <span class="ruby-value">4</span>), <span class="ruby-identifier">caller</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">begin</span>
    <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">call</span>(<span class="ruby-string">&quot;parse&quot;</span>,<span class="ruby-identifier">_res</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">_docname</span>, <span class="ruby-identifier">_overwrite</span>)
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">XMLRPC</span><span class="ruby-operator">::</span><span class="ruby-constant">FaultException</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>    
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">ExistException</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>
  <span class="ruby-keyword">rescue</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ExistException</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;Failed to store resource&quot;</span>, <span class="ruby-value">5</span>), <span class="ruby-identifier">caller</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- storeresource-source -->
          
        </div>

        

        
      </div><!-- storeresource-method -->

    
      <div id="method-i-update_delete" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">update_delete</span><span
            class="method-args">(expr)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Removes all nodes in expr from their document.</p>

<pre>* *Args*    :
  - +expr+ -&gt; &quot;//node()[@id=&quot;RockyRacoon&quot;]
* *Returns* :
  -int handle of query
* *Raises* :
  - +nothing+</pre>
          

          
          <div class="method-source-code" id="update_delete-source">
            <pre><span class="ruby-comment"># File lib/eXistAPI.rb, line 363</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">update_delete</span>(<span class="ruby-identifier">expr</span>)
  <span class="ruby-identifier">query</span> = <span class="ruby-string">&quot;update delete &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">expr</span>
  <span class="ruby-comment">#puts &quot;query #{query}&quot;</span>
  <span class="ruby-identifier">execute_query</span>(<span class="ruby-identifier">query</span>)
<span class="ruby-keyword">rescue</span>  =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>  
<span class="ruby-keyword">end</span></pre>
          </div><!-- update_delete-source -->
          
        </div>

        

        
      </div><!-- update_delete-method -->

    
      <div id="method-i-update_insert" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">update_insert</span><span
            class="method-args">(expr, pos, expr_single)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Inserts the content sequence specified in expr into the element node passed
via exprSingle. exprSingle and expr should evaluate to a node set.  If
exprSingle contains more than one element node, the modification will be 
applied to each of the nodes. The position of the insertion is determined
by  the keywords "into", "following" or "preceding":</p>

<pre>* *Args*    :
  - +expr+ -&gt; The content is appended after the last child node of the specified elements.
  e.g.: &lt;email type=&quot;office&quot;&gt;andrew@gmail.com&lt;/email&gt;, 
  - +pos+ -&gt; The content is inserted immediately after the node specified in exprSingle.
  pos = &quot;into&quot; | &quot;following&quot; | &quot;preceding&quot;
  - +expr_single+ -&gt; The content is inserted before the node specified in exprSingle.
  e.g. '//address[fname=&quot;Andrew&quot;]'
* *Returns* :
  -int handle of query
* *Raises* :
  - +nothing+</pre>
          

          
          <div class="method-source-code" id="update_insert-source">
            <pre><span class="ruby-comment"># File lib/eXistAPI.rb, line 306</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">update_insert</span>(<span class="ruby-identifier">expr</span>, <span class="ruby-identifier">pos</span>, <span class="ruby-identifier">expr_single</span>) 
  <span class="ruby-identifier">query</span> = <span class="ruby-string">&quot;update insert &quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">expr</span><span class="ruby-operator">+</span><span class="ruby-string">&quot; &quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">pos</span><span class="ruby-operator">+</span><span class="ruby-string">&quot; &quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">expr_single</span>
  <span class="ruby-comment">#puts &quot;query #{query}&quot;</span>
  <span class="ruby-identifier">execute_query</span>(<span class="ruby-identifier">query</span>)
<span class="ruby-keyword">rescue</span>  =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>    
<span class="ruby-keyword">end</span></pre>
          </div><!-- update_insert-source -->
          
        </div>

        

        
      </div><!-- update_insert-method -->

    
      <div id="method-i-update_rename" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">update_rename</span><span
            class="method-args">(expr, expr_single)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Renames the nodes in expr using the string value of the first item in 
exprSingle as the new name of the node. expr should evaluate to a set of 
elements or attributes.</p>

<pre>* *Args*    :
  - +expr+ -&gt; //city
  - +expr_single+ -&gt; &quot;town&quot;
* *Returns* :
  -int handle of query
* *Raises* :
  - +nothing+ -&gt;</pre>
          

          
          <div class="method-source-code" id="update_rename-source">
            <pre><span class="ruby-comment"># File lib/eXistAPI.rb, line 383</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">update_rename</span>(<span class="ruby-identifier">expr</span>, <span class="ruby-identifier">expr_single</span>)
  <span class="ruby-identifier">query</span> = <span class="ruby-string">&quot;update rename &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">expr</span> <span class="ruby-operator">+</span> <span class="ruby-string">&quot; as &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">expr_single</span>
  <span class="ruby-comment">#puts &quot;query #{query}&quot;</span>
  <span class="ruby-identifier">execute_query</span>(<span class="ruby-identifier">query</span>)
<span class="ruby-keyword">rescue</span>  =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>  
<span class="ruby-keyword">end</span></pre>
          </div><!-- update_rename-source -->
          
        </div>

        

        
      </div><!-- update_rename-method -->

    
      <div id="method-i-update_replace" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">update_replace</span><span
            class="method-args">(expr, expr_single)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Replaces the nodes returned by expr with the nodes in exprSingle.  expr may
evaluate to a single element, attribute or text node.  If it is an element,
exprSingle should contain a single element node as well.  If it is an
attribute or text node, the value of the attribute or the text  node is set
to the concatenated string values of all nodes in exprSingle.</p>

<pre>* *Args*    :
  - +expr+ -&gt; e.g.: //fname[. = &quot;Andrew&quot;]
  - +expr_single+ -&gt; &lt;fname&gt;Andy&lt;/fname&gt;
* *Returns* :
  -int handle of query
* *Raises* :
  - +nothing+</pre>
          

          
          <div class="method-source-code" id="update_replace-source">
            <pre><span class="ruby-comment"># File lib/eXistAPI.rb, line 328</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">update_replace</span>(<span class="ruby-identifier">expr</span>, <span class="ruby-identifier">expr_single</span>)
  <span class="ruby-identifier">query</span> = <span class="ruby-string">&quot;update replace &quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">expr</span><span class="ruby-operator">+</span><span class="ruby-string">&quot; with &quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">expr_single</span>
  <span class="ruby-identifier">execute_query</span>(<span class="ruby-identifier">query</span>)
<span class="ruby-keyword">rescue</span>  =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>  
<span class="ruby-keyword">end</span></pre>
          </div><!-- update_replace-source -->
          
        </div>

        

        
      </div><!-- update_replace-method -->

    
      <div id="method-i-update_value" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">update_value</span><span
            class="method-args">(expr, expr_single)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Updates the content of all nodes in expr with the items in exprSingle.  If
expr is an attribute or text node, its value will be set to the 
concatenated string value of all items in exprSingle.</p>

<pre>* *Args*    :
  - +expr+ -&gt; &quot;//node()[@id=&quot;RockyRacoon&quot;]/@id&quot;
  - +expr_single+ -&gt; '&quot;RockyR&quot;'
* *Returns* :
  -int handle of query
* *Raises* :
  - +nothing+</pre>
          

          
          <div class="method-source-code" id="update_value-source">
            <pre><span class="ruby-comment"># File lib/eXistAPI.rb, line 347</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">update_value</span>(<span class="ruby-identifier">expr</span>, <span class="ruby-identifier">expr_single</span>)
  <span class="ruby-identifier">query</span> = <span class="ruby-string">&quot;update replace &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">expr</span> <span class="ruby-operator">+</span> <span class="ruby-string">&quot; with &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">expr_single</span>
  <span class="ruby-identifier">execute_query</span>(<span class="ruby-identifier">query</span>)
<span class="ruby-keyword">rescue</span>  =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>  
<span class="ruby-keyword">end</span></pre>
          </div><!-- update_value-source -->
          
        </div>

        

        
      </div><!-- update_value-method -->

    
    </section><!-- public-instance-method-details -->
  
  </section><!-- 5Buntitled-5D -->

</div><!-- documentation -->


<footer id="validator-badges">
  <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
  <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
  <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
</footer>

